import { defineNuxtConfig } from 'nuxt/config'
import { resolve } from 'path'

export default defineNuxtConfig({
  modules: [
    '@pinia/nuxt',
    '@vant/nuxt'
  ],

  css: [
    '~/assets/styles/main.less'
  ],

  plugins: ['~/src/plugins/rem.client.ts'],


  alias: {
    '@': resolve(__dirname, 'src'),
    // 你也可以加其他别名
    '@api': resolve(__dirname, 'src/api'),
    '@components': resolve(__dirname, 'src/components'),
  },

  app: {
    head: {
      viewport: 'width=device-width, initial-scale=1, maximum-scale=1'
    }
  },
  
  vite: {
    css: {
      preprocessorOptions: {
        less: {
          javascriptEnabled: true
        }
      }
    },
    resolve: {
      alias: {
        // 关键：指向带 default 导出的打包版
        'vue$': 'vue/dist/vue.esm-bundler.js'
      }
    },
    ssr: {
      // 在服务端 bundle 时也不要把这些包当 external，引入打包
      noExternal: [
        'vue',
        'vue-router',
        'pinia',
        // 如果你用到 vant，也一并内联
        'vant'
      ]
    }
  },

  nitro: {
    externals: {
      // 把 vue、vue-router、pinia 一并内联进打包产物
      inline: ['vue', 'vue-router', 'pinia']
    }
  }
})
